package org.gradle.springboot.view.excel;

import java.util.Map;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.poi.ss.usermodel.Row;
import org.apache.poi.ss.usermodel.Sheet;
import org.apache.poi.ss.usermodel.Workbook;
import org.springframework.stereotype.Component;
import org.springframework.web.servlet.view.document.AbstractXlsView;

@Component
public class HomePage extends AbstractXlsView {
	
	

	@Override
	protected void buildExcelDocument(Map<String, Object> model, Workbook workbook, HttpServletRequest request,
			HttpServletResponse response) throws Exception {
		String fileName = new String("你好.xls".getBytes("GBK"), "ISO8859-1");
		response.setHeader("Content-Disposition", "attachment; filename=" + fileName);
		Sheet sheet = workbook.createSheet("Spring");
		sheet.setDefaultColumnWidth((short) 12);
		Row row = sheet.createRow(0);
		row.createCell(0).setCellValue("helloworld");
	}

}
